package com.aounhui.productor.controller;

import com.aounhui.common.entity.Result;
import com.aounhui.productor.service.CommodityFactoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author aounhui
 * @version 1.0
 * @date 2021/6/18 13:50
 */
@RestController
@Slf4j
public class CommodityFactoryController {

    @Autowired
    private CommodityFactoryService commodityFactoryService;

    @GetMapping(value = "/productor/factory/get")
    public Result selectFactory(@RequestParam String name) {
        try {
            log.info("查询{} 的生产信息", name);
            return Result.ok(commodityFactoryService.get(name));
        } catch (Exception e) {
            log.error("查询 {} 生产信息失败", name);
            e.printStackTrace();
            return Result.error("查询信息失败");
        }
    }
}
